package presentationTier;

import presentationTier.actions.JTableAction;
import presentationTier.actions.CloseAction;
import presentationTier.actions.ShowAllAction;
import presentationTier.actions.SearchAction;
import presentationTier.actions.ExportToHTMLAction;
import presentationTier.actions.ExportToXMLAction;
import presentationTier.actions.CreateAction;
import presentationTier.actions.DeleteMovieAction;
import presentationTier.actions.ChangeGenreMenuItemAction;
import presentationTier.actions.ChangeMediumMenuItemAction;
import javax.swing.JFrame;
import presentationTier.actions.AddGenreAction;
import javax.swing.JOptionPane;
import presentationTier.actions.AddMediumAction;


/**
 * Hlavni formular aplikace
 * @author vojta
 */
public class MainForm extends JFrame {
    

    /** Creates new form NewJFrame */
    public MainForm() {
            initComponents();

            Global.enableComponents(this, false);
            
    }

    public void error(Exception ex) {
        JOptionPane.showMessageDialog(this, ex, "Error", JOptionPane.ERROR_MESSAGE);
    }

    public void error (String ex) {
        JOptionPane.showMessageDialog(this, ex, "Error", JOptionPane.ERROR_MESSAGE);        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */  
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        BtnOpen = new javax.swing.JButton();
        BtnOpen.addActionListener(new presentationTier.actions.OpenAction(this));
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jTable1.addMouseListener(new JTableAction(this));
        createBtn = new javax.swing.JButton();
        createBtn.addActionListener(new CreateAction(this));
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jSeparator1 = new javax.swing.JSeparator();
        openMenuItem = new javax.swing.JMenuItem();
        openMenuItem.addActionListener(new presentationTier.actions.OpenAction(this));
        createDatabaseMenuItem = new javax.swing.JMenuItem();
        createDatabaseMenuItem.addActionListener(new CreateAction(this));
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        closeMenuItem = new javax.swing.JMenuItem();
        closeMenuItem.addActionListener(new CloseAction(this));
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        jMenu2 = new javax.swing.JMenu();
        addMediumMenuItem = new javax.swing.JMenuItem();
        addMediumMenuItem.addActionListener(new AddMediumAction(this));
        ChangeMediumMenuItem = new javax.swing.JMenuItem();
        ChangeMediumMenuItem.addActionListener(new ChangeMediumMenuItemAction(this));
        jMenu3 = new javax.swing.JMenu();
        addGenreMenuItem = new javax.swing.JMenuItem();
        addGenreMenuItem.addActionListener(new AddGenreAction(this));
        ChangeGenreMenuItem = new javax.swing.JMenuItem();
        ChangeGenreMenuItem.addActionListener(new ChangeGenreMenuItemAction(this));
        jMenu4 = new javax.swing.JMenu();
        addMovieMenuItem = new javax.swing.JMenuItem();
        addMovieMenuItem.addActionListener(new presentationTier.actions.AddMovieAction(this));
        changeMovieMenuItem = new javax.swing.JMenuItem();
        changeMovieMenuItem.addActionListener(new presentationTier.actions.ChangeMovieMenuItemAction(this));
        deleteMovieMenuItem = new javax.swing.JMenuItem();
        deleteMovieMenuItem.addActionListener(new DeleteMovieAction(this));
        jMenu5 = new javax.swing.JMenu();
        searchMenuItem = new javax.swing.JMenuItem();
        searchMenuItem.addActionListener(new SearchAction(this));
        showAllMenuItem = new javax.swing.JMenuItem();
        showAllMenuItem.addActionListener(new ShowAllAction(this));
        jMenu6 = new javax.swing.JMenu();
        exportToXMLMenuItem = new javax.swing.JMenuItem();
        exportToXMLMenuItem.addActionListener(new ExportToXMLAction(this));
        exportToHTMLMenuItem = new javax.swing.JMenuItem();
        exportToHTMLMenuItem.addActionListener(new ExportToHTMLAction(this));

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Movie database");

        BtnOpen.setText("Open database");

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 666, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE)
        );

        createBtn.setText("Create new database");

        jMenu1.setText("File");
        jMenu1.add(jSeparator1);

        openMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        openMenuItem.setText("Open database");
        jMenu1.add(openMenuItem);

        createDatabaseMenuItem.setText("Create database");
        jMenu1.add(createDatabaseMenuItem);
        jMenu1.add(jSeparator3);

        closeMenuItem.setText("Close");
        jMenu1.add(closeMenuItem);
        jMenu1.add(jSeparator2);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Media");

        addMediumMenuItem.setText("Add medium");
        jMenu2.add(addMediumMenuItem);

        ChangeMediumMenuItem.setText("Change medium");
        jMenu2.add(ChangeMediumMenuItem);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Genres");

        addGenreMenuItem.setText("Add genre");
        jMenu3.add(addGenreMenuItem);

        ChangeGenreMenuItem.setText("Change genre");
        jMenu3.add(ChangeGenreMenuItem);

        jMenuBar1.add(jMenu3);

        jMenu4.setText("Movies");

        addMovieMenuItem.setText("Add movie");
        jMenu4.add(addMovieMenuItem);

        changeMovieMenuItem.setText("Change movie");
        jMenu4.add(changeMovieMenuItem);

        deleteMovieMenuItem.setText("Delete movie");
        jMenu4.add(deleteMovieMenuItem);

        jMenuBar1.add(jMenu4);

        jMenu5.setText("Search");

        searchMenuItem.setText("Search");
        jMenu5.add(searchMenuItem);

        showAllMenuItem.setText("Show all");
        jMenu5.add(showAllMenuItem);

        jMenuBar1.add(jMenu5);

        jMenu6.setText("Export");

        exportToXMLMenuItem.setText("Export to XML");
        jMenu6.add(exportToXMLMenuItem);

        exportToHTMLMenuItem.setText("Export to HTML");
        jMenu6.add(exportToHTMLMenuItem);

        jMenuBar1.add(jMenu6);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(createBtn)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(BtnOpen)
                .addContainerGap(272, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {BtnOpen, createBtn});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BtnOpen)
                    .addComponent(createBtn))
                .addGap(18, 18, 18)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the c ommand line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainForm().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BtnOpen;
    private javax.swing.JMenuItem ChangeGenreMenuItem;
    private javax.swing.JMenuItem ChangeMediumMenuItem;
    private javax.swing.JMenuItem addGenreMenuItem;
    private javax.swing.JMenuItem addMediumMenuItem;
    private javax.swing.JMenuItem addMovieMenuItem;
    private javax.swing.JMenuItem changeMovieMenuItem;
    private javax.swing.JMenuItem closeMenuItem;
    private javax.swing.JButton createBtn;
    private javax.swing.JMenuItem createDatabaseMenuItem;
    private javax.swing.JMenuItem deleteMovieMenuItem;
    private javax.swing.JMenuItem exportToHTMLMenuItem;
    private javax.swing.JMenuItem exportToXMLMenuItem;
    public javax.swing.JMenu jMenu1;
    public javax.swing.JMenu jMenu2;
    public javax.swing.JMenu jMenu3;
    public javax.swing.JMenu jMenu4;
    public javax.swing.JMenu jMenu5;
    public javax.swing.JMenu jMenu6;
    public javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    public javax.swing.JTable jTable1;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem searchMenuItem;
    private javax.swing.JMenuItem showAllMenuItem;
    // End of variables declaration//GEN-END:variables

}
